//
//  ViewController.swift
//  SwiftJson源码
//
//  Created by wsj on 2018/3/21.
//  Copyright © 2018年 wsj. All rights reserved.
//

import UIKit
//import SwiftyJSON
class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let label = UILabel.wj_mask().wj_text(text: "七秒").wj_font(font:30).wj_view as! UILabel;
        label.frame = CGRect.init(x: 10, y: 10, width: 90, height: 30);
        view.addSubview(label);
        
        
        _ = UIButton.wj_mask().wj_frame(CGRect.init(x: 100, y: 100, width: 100, height: 100))
        .wj_bgColor(UIColor.red)
        .wj_btnTitle("七秒")
            .wj_btnAction(action: { (button)  in
                let VC = TestController.init();
                self.present(VC, animated: true, completion: nil)
            })
        .wj_addSuperView(self.view);
        
//        let button = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 100, height: 100));
//        button.backgroundColor = UIColor.red;
//        button.addTarget(self, action: #selector(ViewController.buttonAction), for: .touchUpInside);
//        view.addSubview(button)
//
    }
    @objc func buttonAction() {
        let VC = TestController.init();
        self.present(VC, animated: true, completion: nil)
    }
    @available(*,introduced : 10)
    func test()  {
        
    }
    ///  external 表示外部参数，提供外部使用
    ///  local表示局部参数，提供方法里面使用
    ///  当不想使用外部参数的时候，可以使用“_”来代替外部参数
    ///  使用外部参数或者内部参数，可以更好的区分属性和参数
    func externalParameterOrLocalParameter(external local : String) {
        print(local);
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}
extension String {
    subscript(index:Int)->Character{
        set{
            let rangeIndex = self.index(startIndex, offsetBy: index);
            self.replaceSubrange(rangeIndex...rangeIndex, with: String(newValue));
        }
        get{
              return self[self.index(startIndex, offsetBy: index)]
        }
    }
}
struct Matrix {
    let rows: Int
    let cols: Int
    var grid: [Double]
    init(rows: Int, cols: Int) {
        self.rows = rows
        self.cols = cols
        self.grid = Array(repeating: 0.0, count: rows * cols);
    }
    
    func indexIsValidForRow(row: Int, col: Int) -> Bool {
        return row >= 0 && row < rows && col >= 0 && col < cols;
    }
    
    subscript(row: Int, col: Int) -> Double {
        get {
            assert(indexIsValidForRow(row: row, col: col), "index out of range")
            return grid[row * cols + col]
        }
        set {
            assert(indexIsValidForRow(row: row, col: col), "index out of range")
            grid[row * cols + col] = newValue
        }
    }
}



